<?php

//======================================================================
// CATEGORY LARGE FONT
//======================================================================

//-----------------------------------------------------
// Sub-Category Smaller Font
//-----------------------------------------------------

/* Title Here Notice the First Letters are Capitalized */

# Option 1
# Option 2
# Option 3

/*
* This is a detailed explanation
* of something that should require
* several paragraphs of information.
*/
include 'PHPExcel.php';
require_once("dompdf/dompdf_config.inc.php");


$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
$rendererLibrary = 'dompdf.php';
$rendererLibraryPath = dirname(__FILE__). '/dompdf';


$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->SetCellValue('A1', 'Tes');
$objPHPExcel->getActiveSheet()->SetCellValue('B1', 'Image...');
$objPHPExcel->getActiveSheet()->setTitle('Simple');

$objPHPExcel->getActiveSheet()
->getColumnDimension('A')
->setWidth(50);

$objPHPExcel->getActiveSheet()
->getRowDimension('2')
->setRowHeight(200);

// $img = imagecreatefrompng('logo.png');
$data = file_get_contents("logo.png");
// $img = imagecreatefromstring($data);
$fp = fopen("logo1.png","w");
fwrite($fp,$data);
fclose($fp);

$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setPath('logo1.png');

// $objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setName('Test image');
$objDrawing->setDescription('Test image');
// $objDrawing->setImageResource($img);
// $objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG);
// $objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT);
// $objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
$objDrawing->setHeight(150);
$objDrawing->setCoordinates('A2');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());

if (!PHPExcel_Settings::setPdfRenderer($rendererName,$rendererLibraryPath)) {
    die(
        'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
        '<br />' .
        'at the top of this script as appropriate for your directory structure'
    );
}

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->save('test.pdf');

echo date('H:i:s') . " Done writing file.\r\n";
?>